<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 
    <h:head></h:head> 
    <body> 
        <p:layout fullPage="true">  
  
         <p:layoutUnit position="north" size="120" style =" text-align : center;"  > 
    		<style type="text/css">
        	.ui-widget{font-size:90% !important;}  
      		</style> 
      		<a href="http://localhost:8080/TravelDreamFelConRusWeb/employee/employeehome.xhtml">
       <p:graphicImage  value="logo.jpg" style=" height:100px;" />
         </a>
		</p:layoutUnit>  
     
      
        <p:layoutUnit position="west" size="200" header="Pagine utili" resizable="false" closable="false" collapsible="false">   
            <p:menu>  
               
                       <p:menuitem value="Pacchetti" url="http://localhost:8080/TravelDreamFelConRusWeb/employee/packageManagement.xhtml" />  
                     <p:menuitem value="Pagina personale" url="http://localhost:8080/TravelDreamFelConRusWeb/employee/employeePersonal.xhtml" />  
           
            </p:menu>   
                       
        </p:layoutUnit>  
       
      
      <p:layoutUnit position="center">  
	  <h:form id="form">
	  
 <p:dataTable var="giftB" value="#{giftList.giftListModelBought}" rowKey="#{giftB.product.idProduct}" paginator="true" rows="10"  
                  
                 id="giftBtable"
                 rowsPerPageTemplate="10,15,50" >  
   
  
                <f:facet name="header">
                    Elenco prodotti Acquistati
                </f:facet>  
                
                  
                    <p:column  headerText="Prodotto" sortBy="#{giftB.product.name}" >
                     #{giftB.product.name} 
                      </p:column> 
                       <p:column  headerText="Acquistato da" sortBy="#{giftB.idBuyer}" >
                     #{giftB.idBuyer} 
                      </p:column> 
                    
                    

               
                    
              </p:dataTable>
              </h:form>   
              <h:form id= "formAvailable">
                <p:dataTable var="gift" value="#{giftList.giftListModel}" rowKey="#{gift.product.idProduct}" paginator="true" rows="10"  
                selection="#{giftList.selectedGiftList}" selectionMode="single" 
                 id="gifttable"
                 rowsPerPageTemplate="10,15,50" >  
                   <p:ajax event="rowSelect" listener="#{giftList.onRowSelect}"      /> 
  
                <f:facet name="header">
                    Elenco prodotti Disponibili
                </f:facet>  
                
                  
                    <p:column  headerText="Prodotto" sortBy="#{gift.product.name}" >
                     #{gift.product.name} 
                      </p:column> 
                       <p:column  headerText="Costo" sortBy="#{gift.product.cost}" >
                     #{gift.product.cost} 
                      </p:column> 
                    

               
               <f:facet name="footer">
                    <p:commandButton  value="Compra" onclick="PF('sold').show();" type="button" icon="ui-icon-star"/> 
           
                </f:facet>          
              </p:dataTable>
         </h:form>   
         
         
         <h:form style =" text-align : center;">
          <p:button outcome="/index.xhtml" value="Ok, fatto"  icon="ui-icon-arrowrefresh-1-w" ></p:button>
        </h:form> 
    
    
        </p:layoutUnit>  
      
        </p:layout> 
         
          <p:dialog header="Vuoi acquistare il prodotto?" widgetVar="sold" showEffect="explode" hideEffect="bounce" resizable="false">  
     <h:form>
     <h:panelGrid columns="2" cellpadding="5">  
     
          
            <f:facet name="footer">  
                
                  <h:outputLabel for="nameBuyer" value="Nome:" />  
            	<p:inputText value="#{giftList.nameBuyer}" id="nameBuyer" required="true" label="nameBuyer" /> 
          
                <p:commandButton id="buy" value="Ok" update=":form :formAvailable"   
                    actionListener="#{giftList.buyProduct}"  
                   oncomplete="sold.hide();"/>  
                   
                <p:commandButton id="exit" value="Annulla" 
                   oncomplete="sold.hide();"/>  
                
               
            </f:facet>  
        </h:panelGrid>  
        </h:form>
        
        
        	</p:dialog> 
        	
      
                         
             
         
      
<p:growl id="growl" showDetail="true" life="5000" />
         

 
        
    </body> 
    
    
</html>